package com.molichuxing.services.business.service.impl;

import com.molichuxing.framework.dto.Paged;
import com.molichuxing.framework.dto.TabDto;
import com.molichuxing.framework.exception.BizException;
import com.molichuxing.services.business.convertor.Convert;
import com.molichuxing.services.business.dto.request.create.GoodsExclusiveCreateDto;
import com.molichuxing.services.business.dto.request.create.GoodsSubscribeCreateDto;
import com.molichuxing.services.business.dto.response.*;
import com.molichuxing.services.business.service.GoodsBizService;
import com.molichuxing.services.exception.GoodsExceptionCodeEnum;
import com.molichuxing.services.infrastructure.dto.request.create.GoodsSpecCreateDto;
import com.molichuxing.services.infrastructure.dto.response.*;
import com.molichuxing.services.infrastructure.service.*;
import com.molichuxing.services.property.*;
import org.apache.log4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.time.ZoneOffset;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author xuelin yi
 * @create_date: 2019/4/3
 * @name:goods-service
 **/
@Service("goodsBizService")
public class GoodsBizServiceImpl implements GoodsBizService {

    private static final Logger log = Logger.getLogger(GoodsBizServiceImpl.class);

    @Resource
    private GoodsService goodsService;

    @Resource
    private GoodsSpecConfigService goodsSpecConfigService;

    @Resource
    private GoodsSpecService goodsSpecService;

    @Resource
    private GoodsSubscribeService goodsSubscribeService;

    @Resource
    private GoodsSubscribeMileageService goodsSubscribeMileageService;

    @Resource
    private GoodsExclusiveService goodsExclusiveService;

    @Resource
    private GoodsDealerService goodsDealerService;

    @Resource
    private GoodsAuthService goodsAuthService;

    @Override
    public Paged<GoodsBizBizDto> getGoodsList(GoodsTypeEnum goodsTypeEnum, String code, Integer carStyleId, Integer dealerId, int pageNum, int pageSize) {
        log.info("根据条件查询商品列表。goodsType ： [" + goodsTypeEnum + "]" + "code:[" + code + "]" + "carStyleId:[" + carStyleId + "]");
        Paged<GoodsBizBizDto> page = new Paged<>();
        List<GoodsDealerDto> goodsDealerDtoList = null;
        List<TabDto> list = getTabList(dealerId);
        page.setTab(list);
        if (null != dealerId) {
            Map<Integer, List<GoodsDealerDto>> goodsDealerDtoMap = goodsDealerService.getGoodsCountByDealerId(Arrays.asList(dealerId));
            if (null == goodsDealerDtoMap) {
                return page;
            }
            goodsDealerDtoList = goodsDealerDtoMap.get(dealerId);
            if (null == goodsDealerDtoList || goodsDealerDtoList.size() == 0) {
                return page;
            }
        }
        //查询商品信息主表
        Paged<GoodsDto> goodsBasePage = goodsService.getGoodsProductList(goodsTypeEnum, code, carStyleId, dealerId, getGoodsDealerIds(goodsDealerDtoList), pageNum, pageSize);
        BeanUtils.copyProperties(goodsBasePage, page);
        List<GoodsDto> result = goodsBasePage.getList();
        if (null != result && result.size() > 0) {
            //查询商品配置规格信息
            List<GoodsBizBizDto> goodsResult = null;
            if (goodsTypeEnum == GoodsTypeEnum.SUBSCRIBE) {
                goodsResult = composeSubscribeGoodsBase(result, goodsTypeEnum);

            } else if (goodsTypeEnum == GoodsTypeEnum.EXCLUSIVE) {
                goodsResult = composeExclusiveGoodsBase(result, goodsTypeEnum);
            }
            page.setList(Convert.toGoodsBizBeanDto(goodsResult, goodsDealerDtoList));
        }
        page.setTab(list);
        return page;
    }

    private List<TabDto> getTabList(Integer dealerId) {
        List<TabDto> tabList = new ArrayList<>();
        for (GoodsTypeEnum statusEnum : GoodsTypeEnum.values()) {
            int count = 0;
            List<GoodsDto> goodsList = goodsService.getDealerGoodsList(statusEnum, null, null, null, null);
            if ((null != goodsList) && (goodsList.size() > 0)) {
                if ((null != dealerId) && (0 != dealerId)) {
                    count = goodsDealerService.getGoodsCount(goodsList.stream().map(GoodsDto::getId).collect(Collectors.toList()), dealerId);
                } else {
                    count = goodsList.size();
                }
            }
            TabDto tabDto = new TabDto();
            tabDto.setCount(count);
            tabDto.setName(statusEnum.getName());
            tabDto.setType(statusEnum.getValue());
            tabList.add(tabDto);
        }
        return tabList;
    }

    @Override
    public List<GoodsBizBizDto> getDealerGoodsList(Integer dealerId, GoodsTypeEnum goodsTypeEnum, Integer carStyleId) {
        List<GoodsBizBizDto> result = new ArrayList<>();
        List<GoodsDto> goodsList = goodsService.getDealerGoodsList(goodsTypeEnum, carStyleId, null, null, null);
        List<GoodsDealerDto> goodsDealerList = goodsAuthService.getDealerList(null, Arrays.asList(dealerId), null);
        if (null != goodsList && goodsList.size() > 0) {
            //查询商品配置规格信息
            if (goodsTypeEnum == GoodsTypeEnum.SUBSCRIBE) {
                result = composeSubscribeGoodsBase(goodsList, goodsTypeEnum);
            } else if (goodsTypeEnum == GoodsTypeEnum.EXCLUSIVE) {
                result = composeExclusiveGoodsBase(goodsList, goodsTypeEnum);
            } else {
                result = Convert.toGoodsBaseProductDto(goodsList, null, null);
            }
        }
        return Convert.toGoodsBizBizDto(result, goodsDealerList);
    }

    @Override
    public GoodsBaseBizDto getBaseGoods(Integer goodsId) throws Exception {
        GoodsDto goodsDto = goodsService.getGoodsProduct(goodsId);
        if (null == goodsDto) {
            throw new Exception("商品信息不存在");
        }
        List<GoodsSpecConfigDto> goodsProductSpecConfigList = goodsSpecConfigService.getGoodsProductSpecList(
                Arrays.asList(GoodsSpecEnum.DRIVING_TIME_LENGTH.getName(), GoodsSpecEnum.IS_BUY_BACK.getName(), GoodsSpecEnum.PAYMENT_CYCLE.getName()), GoodsTypeEnum.getName(goodsDto.getType()));
        List<GoodsSpecDto> goodsSpecDtoList = goodsSpecService.getGoodsProductSpecList(goodsId, getSpecConfigId(goodsProductSpecConfigList));
        GoodsBaseBizDto goodsBaseBeanDto = Convert.toGoodsBaseDto(goodsDto, goodsSpecDtoList, goodsProductSpecConfigList);
        if (GoodsTypeEnum.SUBSCRIBE.getValue() == goodsDto.getType()) {
            GoodsSubscribeDto goodsSubscribeDto = goodsSubscribeService.getGoodsSubscribeById(goodsId);
            if (null == goodsSubscribeDto) {
                throw new Exception("商品信息不存在");
            }
            goodsBaseBeanDto.setPaymentType(goodsSubscribeDto.getPaymentType());
        } else if (GoodsTypeEnum.EXCLUSIVE.getValue() == goodsDto.getType()) {
            GoodsExclusiveDto goodsExclusiveDto = goodsExclusiveService.getGoodsExclusiveById(goodsId);
            if (null == goodsExclusiveDto) {
                throw new Exception("商品信息不存在");
            }
            goodsBaseBeanDto.setTransferTime(goodsExclusiveDto.getTransferTime());
            goodsBaseBeanDto.setLimitMileage(goodsExclusiveDto.getLimitMileage());
            goodsBaseBeanDto.setPaymentType(goodsExclusiveDto.getPaymentType());
        }
        return goodsBaseBeanDto;
    }

    @Override
    public Boolean isProhibited(Integer goodsId, Integer dealerId) throws Exception {
        GoodsDto goodsDto = goodsService.getGoodsProduct(goodsId);
        if (null == goodsDto) {
            throw new BizException(GoodsExceptionCodeEnum.NOT_EXIST.getCode(), GoodsExceptionCodeEnum.NOT_EXIST.getMessage());
        }
        if (goodsDto.getIsForbidSale()) {
            return true;
        }
        List<GoodsDealerDto> goodsList = goodsAuthService.getDealerList(goodsId, Arrays.asList(dealerId), GoodsDealerStatusEnum.OPEN);
        if ((null == goodsList) || (goodsList.size() == 0)) {
            return true;
        }
        return false;
    }

    @Override
    public GoodsDetailBizDto getDetailGoods(Integer goodsId) throws Exception {
        GoodsDetailBizDto goodsDetailBeanDto = new GoodsDetailBizDto();
        GoodsDto goodsDto = goodsService.getGoodsProduct(goodsId);
        if (null == goodsDto) {
            throw new Exception("商品信息不存在");
        }
        if (GoodsTypeEnum.SUBSCRIBE.getValue() == goodsDto.getType()) {
            GoodsSubscribeDto goodsSubscribeDto = goodsSubscribeService.getGoodsSubscribeById(goodsId);
            if (null == goodsSubscribeDto) {
                throw new Exception("商品信息不存在");
            }
            List<GoodsSubscribeMileageDto> goodsProductSubscribeMileageList = goodsSubscribeMileageService.getGoodsSubscribeMileageById(goodsId);
            return Convert.toGoodsSubscribeDetailDto(goodsDto, goodsSubscribeDto, goodsProductSubscribeMileageList);
        } else {
            GoodsExclusiveDto goodsExclusiveDto = goodsExclusiveService.getGoodsExclusiveById(goodsId);
            if (null == goodsExclusiveDto) {
                throw new Exception("商品信息不存在");
            }
            List<GoodsSpecConfigDto> goodsProductSpecConfigList = goodsSpecConfigService.getGoodsProductSpecList(
                    Arrays.asList(GoodsSpecEnum.PAYMENT_CYCLE.getName(), GoodsSpecEnum.IS_BUY_BACK.getName()), GoodsTypeEnum.getName(goodsDto.getType()));
            List<GoodsSpecDto> goodsSpecDtoList = goodsSpecService.getGoodsProductSpecList(goodsId, getSpecConfigId(goodsProductSpecConfigList));
            return Convert.toGoodsExclusiveDetailDto(goodsDto, goodsExclusiveDto, goodsSpecDtoList, goodsProductSpecConfigList);
        }
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
    public Boolean createExclusiveGoods(GoodsExclusiveCreateDto createDto) throws Exception {
        log.info("新增专属商品信息列表。createDto ： [" + createDto + "]");
        List<GoodsDto> goodsDtoList = goodsService.getDealerGoodsList(GoodsTypeEnum.EXCLUSIVE, createDto.getVehicleStyleId(), createDto.getRental(), createDto.getBond(), null);
        if ((null != goodsDtoList) && (goodsDtoList.size() > 0)) {
            for (GoodsDto goodsDto : goodsDtoList) {
                GoodsExclusiveDto goodsExclusiveDto = goodsExclusiveService.getGoodsExclusiveById(goodsDto.getId());
                if (goodsExclusiveDto.getPaymentType() == createDto.getPaymentType().getValue()) {
                    List<GoodsSpecConfigDto> goodsProductSpecConfigList = goodsSpecConfigService.getGoodsProductSpecList(Arrays.asList(GoodsSpecEnum.DRIVING_TIME_LENGTH.getName(), GoodsSpecEnum.IS_BUY_BACK.getName()), GoodsTypeEnum.EXCLUSIVE);
                    Map<Integer, List<GoodsSpecDto>> specResultMap = goodsSpecService.getGoodsProductSpecList(Arrays.asList(goodsDto.getId()), getSpecConfigId(goodsProductSpecConfigList));
                    if ((null != specResultMap) && (null != specResultMap.get(goodsDto.getId()))) {
                        List<GoodsSpecDto> goodsSpecDtoList = specResultMap.get(goodsDto.getId());
                        if ((null != goodsSpecDtoList) && (goodsSpecDtoList.size() != 0)) {
                            List<String> specsList = goodsSpecDtoList.stream().map(GoodsSpecDto::getSpecsValue).collect(Collectors.toList());
                            if (specsList.contains(createDto.getUseVehicleTimeSpecId() + "") && specsList.contains(createDto.getIsBuyBackSpecId() + "")) {
                                return true;
                            }
                        }
                    }
                }
            }
        }
        createDto.setCode(GoodsCodeEnum.EXCLUSIVE.getName() + (int) ((Math.random() * 9 + 1) * 100000));
        createDto.setType(GoodsTypeEnum.EXCLUSIVE);
        int result = goodsService.createGoodsProduct(createDto);
        if (result > 0) {
            goodsExclusiveService.createExclusiveGoodsProduct(createDto);
            //获取商品的配置信息（用车时长、是否回购）
            Map<Integer, GoodsSpecConfigDto> specConfigMap = goodsSpecConfigService.getGoodsSpecProperties(Arrays.asList(createDto.getUseVehicleTimeSpecId()),
                    Arrays.asList(GoodsSpecEnum.DRIVING_TIME_LENGTH.getName()), GoodsTypeEnum.EXCLUSIVE.getValue());
            Map<Integer, GoodsSpecConfigDto> specIsBuyConfigMap = goodsSpecConfigService.getGoodsSpecProperties(Arrays.asList(createDto.getIsBuyBackSpecId()),
                    Arrays.asList(GoodsSpecEnum.IS_BUY_BACK.getName()), GoodsTypeEnum.EXCLUSIVE.getValue());
            for (Integer key : specIsBuyConfigMap.keySet()) {
                specConfigMap.put(key, specIsBuyConfigMap.get(key));
            }
            goodsSpecService.createGoodsProductSpec(composeGoodsSpec(createDto.getId(), specConfigMap, Arrays.asList(createDto.getUseVehicleTimeSpecId(), createDto.getIsBuyBackSpecId())));
            return true;
        }
        return false;
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
    public Boolean createSubscribeGoods(GoodsSubscribeCreateDto createDto) throws Exception {
        log.info("新增订阅商品信息列表。createDto ： [" + createDto + "]");
        List<GoodsDto> goodsDtoList = goodsService.getDealerGoodsList(GoodsTypeEnum.SUBSCRIBE, createDto.getVehicleStyleId(), createDto.getRental(), null, null);
        if ((null != goodsDtoList) && (goodsDtoList.size() > 0)) {
            for (GoodsDto goodsDto : goodsDtoList) {
                GoodsSubscribeDto goodsSubscribeDto = goodsSubscribeService.getGoodsSubscribeById(goodsDto.getId());
                if (goodsSubscribeDto.getPaymentType() == createDto.getPaymentType().getValue()) {
                    List<GoodsSpecConfigDto> goodsProductSpecConfigList = goodsSpecConfigService.getGoodsProductSpecList(Arrays.asList(GoodsSpecEnum.DRIVING_TIME_LENGTH.getName(), GoodsSpecEnum.IS_BUY_BACK.getName()), GoodsTypeEnum.SUBSCRIBE);
                    Map<Integer, List<GoodsSpecDto>> specResultMap = goodsSpecService.getGoodsProductSpecList(Arrays.asList(goodsDto.getId()), getSpecConfigId(goodsProductSpecConfigList));
                    if ((null != specResultMap) && (null != specResultMap.get(goodsDto.getId()))) {
                        List<GoodsSpecDto> goodsSpecDtoList = specResultMap.get(goodsDto.getId());
                        for (GoodsSpecDto goodsSpecDto : goodsSpecDtoList) {
                            if (goodsSpecDto.getSpecsValue().equals(createDto.getUseVehicleTimeSpecId() + "")) {
                                return true;
                                //throw new BizException(GoodsExceptionCodeEnum.ALREADY_EXISTS.getCode(), GoodsExceptionCodeEnum.ALREADY_EXISTS.getMessage());
                            }
                        }
                    }
                }
            }
        }
        createDto.setCode(GoodsCodeEnum.SUBSCRIBE.getName() + (int) ((Math.random() * 9 + 1) * 100000));
        createDto.setType(GoodsTypeEnum.SUBSCRIBE);
        int result = goodsService.createGoodsProduct(createDto);
        if (result > 0) {
            goodsSubscribeService.createSubscribeGoodsProduct(createDto);
            Map<Integer, GoodsSpecConfigDto> specConfigMap = goodsSpecConfigService.getGoodsSpecProperties(Arrays.asList(createDto.getUseVehicleTimeSpecId()), Arrays.asList(GoodsSpecEnum.DRIVING_TIME_LENGTH.getName()), GoodsTypeEnum.SUBSCRIBE.getValue());
            goodsSpecService.createGoodsProductSpec(composeGoodsSpec(createDto.getId(), specConfigMap, Arrays.asList(createDto.getUseVehicleTimeSpecId())));
            goodsSubscribeMileageService.createGoodsSubscribeMileage(createDto.getId(), createDto.getGoodsPackage());
            return true;
        }
        return false;
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
    public Boolean settingGoodsSale(int goodsId, GoodsForbidSaleEnum goodsForbidSaleEnum) throws Exception {
        Boolean result = goodsService.settingGoodsSale(goodsId, goodsForbidSaleEnum);
        if (result) {
            if (goodsForbidSaleEnum == GoodsForbidSaleEnum.YES) {
                Boolean deleteResult = goodsDealerService.deleteGoodsDealer(goodsId);
                if (!deleteResult) {
                    throw new Exception("经销商不存在");
                }
            }
            return true;
        }
        return false;
    }

    @Override
    public Boolean settingGoodsSaleByDealer(Integer dealerId, GoodsForbidSaleEnum goodsForbidSaleEnum) throws Exception {
        return goodsDealerService.deleteGoodsDealerByDealer(dealerId);
    }

    @Override
    public Map<Integer, List<GoodsDto>> getGoodsListByDealerIds(List<Integer> dealerIds) {
        Map<Integer, List<GoodsDto>> result = new HashMap<>();
        Map<Integer, List<GoodsDealerDto>> goodsDealerMap = goodsDealerService.getGoodsCountByDealerId(dealerIds);
        if (null != goodsDealerMap) {
            for (Integer key : goodsDealerMap.keySet()) {
                List<GoodsDealerDto> list = goodsDealerMap.get(key);
                List<GoodsDto> goodsBizBizList = new ArrayList<>();
                if (null != list && list.size() > 0) {
                    for (GoodsDealerDto goodsDealer : list) {
                        goodsBizBizList.add(goodsService.getGoodsProduct(goodsDealer.getGoodsId()));
                    }
                }
                result.put(key, goodsBizBizList);
            }
        }
        return result;
    }

    @Override
    @Deprecated
    public Paged<GoodsBizBizDto> getAppGoodsList(Integer dealerId, Integer pageNum, Integer pageSize) {
        Paged<GoodsBizBizDto> page = new Paged<>();
        List<GoodsBizBizDto> result = new ArrayList<>();
        List<GoodsDealerDto> goodsDealerList = goodsAuthService.getDealerList(null, Arrays.asList(dealerId), GoodsDealerStatusEnum.OPEN);
        List<GoodsDto> goodsList = goodsService.getDealerGoodsList(null, null, null, null, null);
        result = composeGoods(goodsList);
        List<GoodsBizBizDto> resultGoods = Convert.toGoodsAppDto(result, goodsDealerList);
        resultGoods.sort(Comparator.comparing(GoodsBizBizDto::getType).thenComparing(GoodsBizBizDto::getIsBuyBack).thenComparing(GoodsBizBizDto::getUseVehicleTime).thenComparing(GoodsBizBizDto::getGmtCreate, (o1, o2) -> Integer.parseInt(o2.toEpochSecond(ZoneOffset.of("+8")) + "") - Integer.parseInt(o1.toEpochSecond(ZoneOffset.of("+8")) + "")));
        int count = resultGoods.size();
        resultGoods = resultGoods.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
        page.setList(resultGoods);
        page.setPageSize(pageSize);
        return new Paged<>(resultGoods, count, pageSize);
    }

    /**
     * 根据经销商ID获取商品信息列表
     *
     * @param dealerId
     * @param selectParam goodsType 1:专属，2：订阅  startBudget :开始预算   endBudget :结束预算  startTime :开始时间   endTime :结束时间
     * @param sortFlag    1：全部车型，2：帮您选车，3：日常代步，4：热销车型，5：产品列表
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public Paged<GoodsBizBizDto> getAppGoodsListNew(Integer dealerId, Map<String, Object> selectParam,
                                                    Integer sortFlag, Integer pageNum, Integer pageSize) {
        Paged<GoodsBizBizDto> page = new Paged<>();
        List<GoodsDealerDto> goodsDealerList = goodsAuthService.getDealerList(null, Arrays.asList(dealerId), GoodsDealerStatusEnum.OPEN);
        List<GoodsDto> goodsList = goodsService.getDealerGoodsList(null, null, null, null, null);
        List<GoodsBizBizDto> result = composeGoods(goodsList);
        List<GoodsBizBizDto> resultGoods = Convert.toGoodsAppDto(result, goodsDealerList);
        if (null != selectParam) {
            if (null != selectParam.get("goodsType")) {
                String[] goodsTypes = (selectParam.get("goodsType").toString()).split(",");
                if (goodsTypes.length == 1) {
                    resultGoods = resultGoods.stream().filter(s -> s.getType() == Integer.parseInt(goodsTypes[0])).collect(Collectors.toList());
                }
            }
            if (null != selectParam.get("startBudget")) {
                resultGoods = resultGoods.stream().filter(s -> Double.parseDouble(s.getMileagePrice()) >= Double.parseDouble(selectParam.get("startBudget").toString())).collect(Collectors.toList());
            }
            if (null != selectParam.get("endBudget")) {
                resultGoods = resultGoods.stream().filter(s -> Double.parseDouble(s.getMileagePrice()) < Double.parseDouble(selectParam.get("endBudget").toString())).collect(Collectors.toList());
            }
            if (null != selectParam.get("startTime")) {
                resultGoods = resultGoods.stream().filter(s -> s.getUseVehicleTime() >= Integer.parseInt(selectParam.get("startTime").toString())).collect(Collectors.toList());
            }
            if (null != selectParam.get("endTime")) {
                resultGoods = resultGoods.stream().filter(s -> s.getUseVehicleTime() < Integer.parseInt(selectParam.get("endTime").toString())).collect(Collectors.toList());
            }
        }
        if (GoodsHomePageSortEnum.DAILY_WALK.getValue() == sortFlag) {
            resultGoods.sort((o1, o2) -> Double.parseDouble(o1.getMileagePrice()) >= Double.parseDouble(o2.getMileagePrice()) ? 1 : -1);
            resultGoods.sort((o1, o2) -> Double.parseDouble(o1.getMonthlySupply()) >= Double.parseDouble(o2.getMonthlySupply()) ? 1 : -1);
        } else if (GoodsHomePageSortEnum.HOT_SELLING_MODELS.getValue() == sortFlag) {
            resultGoods.sort((o1, o2) -> Double.parseDouble(o1.getMonthlySupply()) >= Double.parseDouble(o2.getMonthlySupply()) ? -1 : 1);
            resultGoods.sort(Comparator.comparing(GoodsBizBizDto::getType).reversed());
        } else if (GoodsHomePageSortEnum.GOODS_LIST.getValue() == sortFlag) {
            resultGoods.sort(Comparator.comparing(GoodsBizBizDto::getUseVehicleTime).reversed());
            resultGoods.sort((o1, o2) -> Double.parseDouble(o1.getMileagePrice()) >= Double.parseDouble(o2.getMileagePrice()) ? 1 : -1);
        } else {
            resultGoods.sort(Comparator.comparing(GoodsBizBizDto::getType).thenComparing(GoodsBizBizDto::getIsBuyBack).thenComparing(GoodsBizBizDto::getUseVehicleTime).thenComparing(GoodsBizBizDto::getGmtCreate, (o1, o2) -> Integer.parseInt(o2.toEpochSecond(ZoneOffset.of("+8")) + "") - Integer.parseInt(o1.toEpochSecond(ZoneOffset.of("+8")) + "")));
        }
        int count = resultGoods.size();
        resultGoods = resultGoods.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
        page.setList(resultGoods);
        page.setPageSize(pageSize);
        return new Paged<>(resultGoods, count, pageSize);
    }

    @Override
    public List<GoodsBizBizDto> getAppGoodsByIds(List<Integer> goodsIds) {
        List<GoodsBizBizDto> result = new ArrayList<>();
        List<GoodsDto> goodsDtoList = goodsService.getGoodsProductList(goodsIds, null);
        if ((null == goodsDtoList) || (goodsDtoList.size() == 0)) {
            return null;
        }
        result = composeGoods(goodsDtoList);
        return Convert.toGoodsAppByIdsDto(goodsIds, result);
    }

    private List<GoodsBizBizDto> composeGoods(List<GoodsDto> goodsDtoList) {
        return composeGoods(goodsDtoList, null);
    }

    private List<GoodsBizBizDto> composeGoods(List<GoodsDto> goodsDtoList, GoodsExclusiveTypeEnum goodsExclusiveType) {
        List<GoodsBizBizDto> result = new ArrayList<>();
        if (null != goodsDtoList && goodsDtoList.size() > 0) {
            //查询商品配置规格信息
            Map<Integer, List<GoodsDto>> map = goodsDtoList.stream().collect(Collectors.groupingBy(GoodsDto::getType));
            if (null != map) {
                if (null != map.get(GoodsTypeEnum.SUBSCRIBE.getValue())) {
                    result.addAll(composeSubscribeGoodsBase(map.get(GoodsTypeEnum.SUBSCRIBE.getValue()), GoodsTypeEnum.SUBSCRIBE));
                }
                if (null != map.get(GoodsTypeEnum.EXCLUSIVE.getValue())) {
                    result.addAll(composeExclusiveGoodsBase(map.get(GoodsTypeEnum.EXCLUSIVE.getValue()), GoodsTypeEnum.EXCLUSIVE, goodsExclusiveType));
                }
            }
        }
        return result;
    }

    @Override
    public GoodsOrderBizDto getGoodsForOrder(Integer goodsId, Integer packageId) throws Exception {
        GoodsOrderBizDto goodsOrderBizDto = new GoodsOrderBizDto();
        GoodsDto goodsDto = goodsService.getGoodsProduct(goodsId);
        if (null == goodsDto) {
            throw new Exception("商品信息不存在");
        }
        List<GoodsSpecConfigDto> goodsProductSpecConfigList = goodsSpecConfigService.getGoodsProductSpecList(
                Arrays.asList(GoodsSpecEnum.DRIVING_TIME_LENGTH.getName(), GoodsSpecEnum.IS_BUY_BACK.getName(), GoodsSpecEnum.PAYMENT_CYCLE.getName()), GoodsTypeEnum.getName(goodsDto.getType()));
        List<GoodsSpecDto> goodsSpecDtoList = goodsSpecService.getGoodsProductSpecList(goodsId, getSpecConfigId(goodsProductSpecConfigList));
        GoodsBaseBizDto goodsBaseBeanDto = Convert.toGoodsBaseDto(goodsDto, goodsSpecDtoList, goodsProductSpecConfigList);
        if (GoodsTypeEnum.SUBSCRIBE.getValue() == goodsDto.getType()) {
            GoodsSubscribeDto goodsSubscribeDto = goodsSubscribeService.getGoodsSubscribeById(goodsId);
            if (null == goodsSubscribeDto) {
                throw new Exception("商品信息不存在");
            }
            goodsOrderBizDto = Convert.toGoodsOrderBizDto(goodsBaseBeanDto, goodsSubscribeDto, goodsSubscribeMileageService.getSubscribeMileageById(packageId));
        } else if (GoodsTypeEnum.EXCLUSIVE.getValue() == goodsDto.getType()) {
            GoodsExclusiveDto goodsExclusiveDto = goodsExclusiveService.getGoodsExclusiveById(goodsId);
            if (null == goodsExclusiveDto) {
                throw new Exception("商品信息不存在");
            }
            goodsOrderBizDto = Convert.toGoodsOrderBizDto(goodsBaseBeanDto, goodsExclusiveDto);
        }
        return goodsOrderBizDto;
    }


    @Override
    public GoodsExclusiveDrawerBizDto getAppExclusiveGoods(Integer goodsId, Integer dealerId) throws Exception {
        GoodsDto goodsDto = goodsService.getGoodsProduct(goodsId);
        if (null == goodsDto) {
            throw new Exception("商品信息不存在");
        }
        List<GoodsSpecConfigDto> goodsProductSpecConfigList = goodsSpecConfigService.getGoodsProductSpecList(
                Arrays.asList(GoodsSpecEnum.DRIVING_TIME_LENGTH.getName(), GoodsSpecEnum.IS_BUY_BACK.getName(), GoodsSpecEnum.PAYMENT_CYCLE.getName()), GoodsTypeEnum.getName(goodsDto.getType()));
        List<GoodsSpecDto> goodsSpecDtoList = goodsSpecService.getGoodsProductSpecList(goodsId, getSpecConfigId(goodsProductSpecConfigList));
        GoodsBaseBizDto goodsBaseBeanDto = Convert.toGoodsBaseDto(goodsDto, goodsSpecDtoList, goodsProductSpecConfigList);
        GoodsExclusiveDto goodsExclusiveDto = goodsExclusiveService.getGoodsExclusiveById(goodsId);
        if (null == goodsExclusiveDto) {
            throw new Exception("商品信息不存在");
        }
        GoodsExclusiveDrawerBizDto goodsExclusiveDrawerBizDto = Convert.toGoodsDrawerBizDto(goodsBaseBeanDto, goodsExclusiveDto);
        //获取车型下的规格信息
        List<GoodsDealerDto> goodsDealerList = goodsAuthService.getDealerList(null, Arrays.asList(dealerId), GoodsDealerStatusEnum.OPEN);
        List<Integer> drawerGoodsIds = new ArrayList<>();
        if ((null != goodsDealerList) && (goodsDealerList.size() > 0)) {
            drawerGoodsIds = goodsDealerList.stream().map(GoodsDealerDto::getGoodsId).collect(Collectors.toList());
        }
        List<GoodsDto> goodsList = goodsService.getDealerGoodsList(GoodsTypeEnum.EXCLUSIVE, goodsDto.getVehicleStyleId(), null, null, drawerGoodsIds);
        List<GoodsBizBizDto> goodsResult = composeExclusiveGoodsBase(goodsList, GoodsTypeEnum.EXCLUSIVE);
        return Convert.toGoodsDrawerBizDto(goodsExclusiveDrawerBizDto, goodsResult);
    }

    @Override
    public GoodsSubscribeDrawerBizDto getAppSubscribeGoods(Integer goodsId, Integer packageId, Integer dealerId) throws Exception {
        GoodsDto goodsDto = goodsService.getGoodsProduct(goodsId);
        if (null == goodsDto) {
            throw new BizException(GoodsExceptionCodeEnum.NOT_EXIST.getCode(), GoodsExceptionCodeEnum.NOT_EXIST.getMessage());
        }
        List<GoodsSpecConfigDto> goodsProductSpecConfigList = goodsSpecConfigService.getGoodsProductSpecList(
                Arrays.asList(GoodsSpecEnum.DRIVING_TIME_LENGTH.getName(), GoodsSpecEnum.IS_BUY_BACK.getName(), GoodsSpecEnum.PAYMENT_CYCLE.getName()), GoodsTypeEnum.getName(goodsDto.getType()));
        List<GoodsSpecDto> goodsSpecDtoList = goodsSpecService.getGoodsProductSpecList(goodsId, getSpecConfigId(goodsProductSpecConfigList));
        GoodsBaseBizDto goodsBaseBeanDto = Convert.toGoodsBaseDto(goodsDto, goodsSpecDtoList, goodsProductSpecConfigList);
        GoodsSubscribeDto goodsSubscribe = goodsSubscribeService.getGoodsSubscribeById(goodsId);
        if (null == goodsSubscribe) {
            throw new BizException(GoodsExceptionCodeEnum.NOT_EXIST.getCode(), GoodsExceptionCodeEnum.NOT_EXIST.getMessage());
        }
        GoodsSubscribeMileageDto goodsSubscribeMileage = goodsSubscribeMileageService.getSubscribeMileageById(packageId);
        if (null == goodsSubscribeMileage) {
            throw new BizException(GoodsExceptionCodeEnum.NOT_EXIST.getCode(), GoodsExceptionCodeEnum.NOT_EXIST.getMessage());
        }
        GoodsSubscribeDrawerBizDto goodsSubscribeDrawer = Convert.toGoodsSubscribeDrawerBizDto(goodsBaseBeanDto, goodsSubscribe, goodsSubscribeMileage);
        List<GoodsDealerDto> goodsDealerList = goodsAuthService.getDealerList(null, Arrays.asList(dealerId), GoodsDealerStatusEnum.OPEN);
        List<Integer> drawerGoodsIds = new ArrayList<>();
        if ((null != goodsDealerList) && (goodsDealerList.size() > 0)) {
            drawerGoodsIds = goodsDealerList.stream().map(GoodsDealerDto::getGoodsId).collect(Collectors.toList());
        }
        List<GoodsDto> goodsList = goodsService.getDealerGoodsList(GoodsTypeEnum.SUBSCRIBE, goodsDto.getVehicleStyleId(), null, null, drawerGoodsIds);
        List<GoodsBizBizDto> goodsResult = composeSubscribeGoodsBase(goodsList, GoodsTypeEnum.SUBSCRIBE);
        return Convert.toGoodsDrawerBizDto(goodsSubscribeDrawer, goodsResult);
    }

    @Override
    public List<GoodsReletMileageBizDto> getGoodsMileage(Integer goodsId, Integer dealerId) throws Exception {
        GoodsDto goodsDto = goodsService.getGoodsProduct(goodsId);
        if (null == goodsDto) {
            throw new BizException(GoodsExceptionCodeEnum.NOT_EXIST.getCode(), GoodsExceptionCodeEnum.NOT_EXIST.getMessage());
        }
        List<Integer> goodsIds = null;
        if (null != dealerId) {
            Map<Integer, List<GoodsDealerDto>> goodsDealerDtoMap = goodsDealerService.getGoodsCountByDealerId(Arrays.asList(dealerId));
            if (null != goodsDealerDtoMap) {
                List<GoodsDealerDto> goodsDealerDtoList = goodsDealerDtoMap.get(dealerId);
                if ((null != goodsDealerDtoList) && (goodsDealerDtoList.size() > 0)) {
                    goodsIds = new ArrayList<>();
                    goodsIds = goodsDealerDtoList.stream().map(GoodsDealerDto::getGoodsId).collect(Collectors.toList());
                }
            }
        }
        List<GoodsDto> goodsDtoList = goodsService.getDealerGoodsList(GoodsTypeEnum.SUBSCRIBE, goodsDto.getVehicleStyleId(), null, null, goodsIds);
        if (null == goodsDtoList || goodsDtoList.size() == 0) {
            return null;
        }
        List<GoodsBizBizDto> result = composeSubscribeGoodsBase(goodsDtoList, GoodsTypeEnum.SUBSCRIBE);
        return Convert.toGoodsReletMileageBizDto(result);
    }

    @Override
    public List<GoodsMileagePackageReletBizDto> getGoodsMileagePackage(Integer goodsId, Integer dealerId, GoodsMileageSubscribeEnum goodsMileageSubscribeEnum) throws Exception {
        GoodsDto goodsDto = goodsService.getGoodsProduct(goodsId);
        if (null == goodsDto) {
            throw new BizException(GoodsExceptionCodeEnum.NOT_EXIST.getCode(), GoodsExceptionCodeEnum.NOT_EXIST.getMessage());
        }
        List<GoodsDealerDto> goodsDealerList = goodsAuthService.getDealerList(null, Arrays.asList(dealerId), GoodsDealerStatusEnum.OPEN);
        List<GoodsDto> goodsList = goodsService.getDealerGoodsList(GoodsTypeEnum.SUBSCRIBE, goodsDto.getVehicleStyleId(), null, null, null);
        List<GoodsBizBizDto> result = composeGoods(goodsList);
        List<GoodsBizBizDto> resultGoods = Convert.toGoodsAppDto(result, goodsDealerList);
        if ((null == resultGoods) || (resultGoods.size() == 0)) {
            return null;
        }
        Map<Integer, List<GoodsBizBizDto>> goodsBizBizDtoMap = resultGoods.stream().collect(Collectors.groupingBy(GoodsBizBizDto::getUseVehicleTime));
        List<GoodsBizBizDto> goodsBizBizDtoList = new ArrayList<>();
        switch (goodsMileageSubscribeEnum) {
            case ONE:
                if (null != goodsBizBizDtoMap.get(goodsMileageSubscribeEnum.getValue())) {
                    goodsBizBizDtoList = goodsBizBizDtoMap.get(goodsMileageSubscribeEnum.getValue());
                }
                break;
            case TWO:
                if (null != goodsBizBizDtoMap.get(GoodsMileageSubscribeEnum.TWO.getValue())) {
                    goodsBizBizDtoList = goodsBizBizDtoMap.get(GoodsMileageSubscribeEnum.TWO.getValue());
                }
                if (null != goodsBizBizDtoMap.get(GoodsMileageSubscribeEnum.ONE.getValue())) {
                    goodsBizBizDtoList.addAll(goodsBizBizDtoMap.get(GoodsMileageSubscribeEnum.ONE.getValue()));
                }
                break;
            case THREE:
                if (null != goodsBizBizDtoMap.get(GoodsMileageSubscribeEnum.TWO.getValue())) {
                    goodsBizBizDtoList = goodsBizBizDtoMap.get(GoodsMileageSubscribeEnum.TWO.getValue());
                }
                if (null != goodsBizBizDtoMap.get(GoodsMileageSubscribeEnum.ONE.getValue())) {
                    goodsBizBizDtoList.addAll(goodsBizBizDtoMap.get(GoodsMileageSubscribeEnum.ONE.getValue()));
                }
                if (null != goodsBizBizDtoMap.get(GoodsMileageSubscribeEnum.THREE.getValue())) {
                    goodsBizBizDtoList.addAll(goodsBizBizDtoMap.get(GoodsMileageSubscribeEnum.THREE.getValue()));
                }
                break;
        }
        //去重数据
        List<GoodsMileagePackageReletBizDto> goodsResult = Convert.toGoodsMileagePackageReletDto(goodsBizBizDtoList);
        Map<Integer, List<GoodsMileagePackageReletBizDto>> reletMap = goodsResult.stream().collect(Collectors.groupingBy(GoodsMileagePackageReletBizDto::getMiles));
        if ((null == reletMap)) {
            return null;
        }
        List<GoodsMileagePackageReletBizDto> dataResult = new ArrayList<>();
        for (Integer key : reletMap.keySet()) {
            List<GoodsMileagePackageReletBizDto> goodsMileagePackageReletBizDtoList = reletMap.get(key);
            if ((null == goodsMileagePackageReletBizDtoList) || (goodsMileagePackageReletBizDtoList.size() == 0)) {
                continue;
            }
            List<GoodsMileagePackageReletBizDto> sortedEmp = goodsMileagePackageReletBizDtoList.stream().sorted(Comparator.comparing(GoodsMileagePackageReletBizDto::getFee).reversed()).collect(Collectors.toList());
            dataResult.add(sortedEmp.get(0));
        }
        dataResult = dataResult.stream().sorted(Comparator.comparing(GoodsMileagePackageReletBizDto::getMiles)).collect(Collectors.toList());
        return dataResult;
    }

    @Override
    public List<Integer> getModelIdByDealerId(Integer dealerId) {
        List<GoodsDealerDto> goodsDealerList = goodsAuthService.getDealerList(null, Arrays.asList(dealerId), GoodsDealerStatusEnum.OPEN);
        if ((null == goodsDealerList) || (goodsDealerList.size() == 0)) {
            return null;
        }
        List<Integer> goodsIds = new ArrayList<>();
        for (GoodsDealerDto goodsDealer : goodsDealerList) {
            goodsIds.add(goodsDealer.getGoodsId());
        }
        List<GoodsDto> goodsDtoList = goodsService.getGoodsProductList(goodsIds, null);
        if ((null == goodsDtoList) || (goodsDtoList.size() == 0)) {
            return null;
        }
        List<Integer> result = new ArrayList<>();
        for (GoodsDto goods : goodsDtoList) {
            result.add(goods.getVehicleStyleId());
        }
        return result;
    }

    @Override
    public List<GoodsBigScreenBizDto> getBigScreenGoodsList(Integer dealerId, List<Integer> vehicleIds) {
        List<GoodsDealerDto> goodsDealerList = goodsAuthService.getDealerList(null, Arrays.asList(dealerId), GoodsDealerStatusEnum.OPEN);
        if ((null == goodsDealerList) || (goodsDealerList.size() == 0)) {
            return null;
        }
        List<Integer> goodsIds = new ArrayList<>();
        for (GoodsDealerDto goodsDealer : goodsDealerList) {
            goodsIds.add(goodsDealer.getGoodsId());
        }
        List<GoodsDto> goodsList = goodsService.getGoodsProductList(goodsIds, vehicleIds);
        if ((null == goodsList) || (goodsList.size() == 0)) {
            return null;
        }
        Map<Integer, List<GoodsDto>> goodsGroupMap = goodsList.stream().collect(Collectors.groupingBy(GoodsDto::getType));
        Map<Integer, List<GoodsBizBizDto>> goodsExclusiveMap = null;
        Map<Integer, List<GoodsBizBizDto>> goodsSubscribeMap = null;
        if (null != goodsGroupMap.get(GoodsTypeEnum.EXCLUSIVE.getValue())) {
            //获取车型下的规格信息
            List<GoodsBizBizDto> goodsExclusiveResult = composeExclusiveGoodsBase(goodsGroupMap.get(GoodsTypeEnum.EXCLUSIVE.getValue()), GoodsTypeEnum.EXCLUSIVE);
            goodsExclusiveMap = goodsExclusiveResult.stream().collect(Collectors.groupingBy(GoodsBizBizDto::getVehicleStyleId));
        }
        if (null != goodsGroupMap.get(GoodsTypeEnum.SUBSCRIBE.getValue())) {
            List<GoodsBizBizDto> goodsSubscribeResult = composeSubscribeGoodsBase(goodsGroupMap.get(GoodsTypeEnum.SUBSCRIBE.getValue()), GoodsTypeEnum.SUBSCRIBE);
            goodsSubscribeMap = goodsSubscribeResult.stream().collect(Collectors.groupingBy(GoodsBizBizDto::getVehicleStyleId));
        }
        //对该经销商下的商品 获取车型去重
        List<Integer> vehicleIdsList = goodsList.stream().map(GoodsDto::getVehicleStyleId).distinct().collect(Collectors.toList());
        List<GoodsBigScreenBizDto> result = new ArrayList<>();
        for (Integer vehicleId : vehicleIdsList) {
            GoodsBigScreenBizDto goodsBigScreenBizDto = new GoodsBigScreenBizDto();
            goodsBigScreenBizDto.setVehicleStyleId(vehicleId);
            //专属商品
            if (null != goodsExclusiveMap) {
                goodsBigScreenBizDto.setSpecList(Convert.toGoodsBigScreenDrawerSpecBizDto(goodsExclusiveMap.get(vehicleId)));
            }
            //订阅商品
            if (null != goodsSubscribeMap) {
                goodsBigScreenBizDto.setMileageList(Convert.toGoodsBigScreenDrawerMileageBizDto(goodsSubscribeMap.get(vehicleId)));
            }
            result.add(goodsBigScreenBizDto);
        }
        return result;
    }


    private List<GoodsSpecCreateDto> composeGoodsSpec(int goodsId, Map<Integer, GoodsSpecConfigDto> specConfigMap, List<Integer> specIds) {
        List<GoodsSpecCreateDto> goodsSpecList = new ArrayList<>();
        for (Integer specId : specConfigMap.keySet()) {
            GoodsSpecCreateDto goodsSpecCreateDto = new GoodsSpecCreateDto();
            goodsSpecCreateDto.setGoodsId(goodsId);
            goodsSpecCreateDto.setSpecsId(specConfigMap.get(specId).getId());
            goodsSpecCreateDto.setSpecsValue(specConfigMap.get(specId).getProperties());
            goodsSpecList.add(goodsSpecCreateDto);
        }
        return goodsSpecList;
    }

    /**
     * 组合商品的基础信息列表
     *
     * @param result
     * @param goodsTypeEnum
     * @return
     */
    private List<GoodsBizBizDto> composeGoodsBase(List<GoodsDto> result, GoodsTypeEnum goodsTypeEnum) {
        getDistribution(result);
        List<GoodsSpecConfigDto> goodsProductSpecConfigList = goodsSpecConfigService.getGoodsProductSpecList(Arrays.asList(GoodsSpecEnum.DRIVING_TIME_LENGTH.getName(), GoodsSpecEnum.IS_BUY_BACK.getName()), goodsTypeEnum);
        Map<Integer, List<GoodsSpecDto>> specResultMap = goodsSpecService.getGoodsProductSpecList(getGoodsIds(result), getSpecConfigId(goodsProductSpecConfigList));
        return Convert.toGoodsBaseProductDto(result, specResultMap, goodsProductSpecConfigList);
    }

    /**
     * 组合订阅商品的信息列表
     *
     * @param result
     * @param goodsTypeEnum
     * @return
     */
    private List<GoodsBizBizDto> composeSubscribeGoodsBase(List<GoodsDto> result, GoodsTypeEnum goodsTypeEnum) {
        List<GoodsBizBizDto> goodsResult = composeGoodsBase(result, goodsTypeEnum);
        Map<Integer, GoodsSubscribeDto> goodsProductSubscribeMap = goodsSubscribeService.getGoodsSubscribeById(getGoodsIds(result));
        Map<Integer, List<GoodsSubscribeMileageDto>> goodsSubscribeMileageMap = goodsSubscribeMileageService.getGoodsSubscribeMileageById(getGoodsIds(result));
        return Convert.toGoodsSubscribeProductDto(goodsResult, goodsProductSubscribeMap, goodsSubscribeMileageMap);
    }


    /**
     * 组合专属商品的信息列表-全部
     *
     * @param result
     * @param goodsTypeEnum
     * @return
     */
    private List<GoodsBizBizDto> composeExclusiveGoodsBase(List<GoodsDto> result, GoodsTypeEnum goodsTypeEnum) {
        return composeExclusiveGoodsBase(result, goodsTypeEnum, null);
    }

    /**
     * 组合专属商品的信息列表
     *
     * @param result
     * @param goodsTypeEnum
     * @param goodsExclusiveType 征信类型（null查全部）
     * @return
     */
    private List<GoodsBizBizDto> composeExclusiveGoodsBase(List<GoodsDto> result, GoodsTypeEnum goodsTypeEnum,
                                                           GoodsExclusiveTypeEnum goodsExclusiveType) {
        return Convert.toGoodsExclusiveProductDto(composeGoodsBase(result, goodsTypeEnum),
                goodsExclusiveService.getGoodsExclusiveByIds(getGoodsIds(result), goodsExclusiveType));
    }

    private List<Integer> getSpecConfigId(List<GoodsSpecConfigDto> goodsProductSpecConfigList) {
        if ((null != goodsProductSpecConfigList) && (goodsProductSpecConfigList.size() > 0)) {
            List<Integer> result = new ArrayList<>();
            for (GoodsSpecConfigDto goodsSpecConfigDto : goodsProductSpecConfigList) {
                result.add(goodsSpecConfigDto.getId());
            }
            return result;
        }
        return null;
    }

    private List<Integer> getGoodsIds(List<GoodsDto> goodsDtoList) {
        if ((null != goodsDtoList) && (goodsDtoList.size() > 0)) {
            List<Integer> result = new ArrayList<>();
            for (GoodsDto goodsDto : goodsDtoList) {
                result.add(goodsDto.getId());
            }
            return result;
        }
        return null;
    }

    private List<Integer> getGoodsDealerIds(List<GoodsDealerDto> goodsDealerDtoList) {
        if ((null != goodsDealerDtoList) && (goodsDealerDtoList.size() > 0)) {
            List<Integer> result = new ArrayList<>();
            for (GoodsDealerDto goodsDto : goodsDealerDtoList) {
                result.add(goodsDto.getGoodsId());
            }
            return result;
        }
        return null;
    }

    private void getDistribution(List<GoodsDto> result) {
        for (GoodsDto goodsDto : result) {
            int count = goodsDealerService.getDealerCountByGoodsId(goodsDto.getId());
            if (count > 0) {
                goodsDto.setIsDistribution(true);
            } else {
                goodsDto.setIsDistribution(false);
            }
        }
    }

}
